Technical Q&A QA1264
Generating an NMI Without a Programmer's Switch


Q: I need to do remote debugging on a Power Macintosh G4 (Mirrored Drive Doors) which is hung in the kernel. This machine doesn't have a programmer's switch, so how can I attach to this system from a remote GDB session?

A: Starting with Mac OS X 10.1.2, if Mac OS X is started while the Open Firmware debug flags have the DB_NMI bit set, pressing the system's power button will generate a non-maskable interrupt (NMI) instead of sleeping or waking the system. This feature works on systems that do not have a physical programmer's switch.



Note:
On portables such as the iBook or PowerBook, hold down the command key while pressing the power button to generate an NMI.



The system reads the debug flags at boot time from the boot-args configuration variable.

To set the DB_NMI bit, start by entering this command in Terminal:

% nvram boot-args

This will display the current setting of the debug flags. Now, add debug=0x4 to the current settings with this command:

% sudo nvram boot-args="<current settings> debug=0x4"

For more information about the debug flags, please see Kernel Programming .



Note:
If the power button is pressed for more than five seconds, the system will immediately power off.



The power button will retain this functionality until Mac OS X is restarted without the DB_NMI bit set. You can clear this bit by issuing the nvram command omitting debug=0x4 :

% sudo nvram boot-args=""



Note:
This bit will be cleared if you use System Preferences to change the startup disk. It may be cleared if you perform an installation that requires a restart.




[Apr 22, 2004]


Developer Documentation | Technical Notes | Development Kits | Sample Code